# tuple = ({'0':'零'},{'1':'壹'},{'2':'贰'},{'3':'叁'},{'4':'肆'},{'5':'伍'},
# {'6':'陆'},{'7':'柒'},{'8':'捌'},{'9':'玖'})
# while True:
#     Bigwrite = input('请输入您要查询的数字(0~9):')
#     num = int(Bigwrite)
#     str = tuple[num][Bigwrite]
#     print(str)

import random

words = {}
while True:
    print('========欢迎来到生词本系统=========')
    print('=====1.添加单词    2.删除单词=====')
    print('=====3.清空单词    4.查看单词=====')
    print('=====5.背诵单词    6.退出系统=====')
    print('===============================')
    choice = input('请输入数字1-6进行操作：')
    if choice == '1':
        word = input('请输入您要添加的单词：')
        if word in words:
            print('该单词已存在，添加失败')
            continue
        meaning = input('请输入您要添加的单词意思：')
        words[word] = meaning
        print("添加成功")
    elif choice == '2':
        word = input('请输入您要删除的单词：')
        if word not in words:
            print('该单词不存在，删除失败')
            continue
        del words[word]
        print("删除成功")
    elif choice == '3':
        words.clear()
        print('清空单词成功')
    elif choice == '4':
        if len(words) != 0:
            print(words)
        else:
            print('生词本内容为空')
    elif choice == '5':
        wordlist = list(words.keys())
        rand = random.randint(0, len(wordlist) - 1)
        meaning = input(f'请输入单词{wordlist[rand]}的意思：')
        count = 2
        while count > 0:
            if meaning == words[wordlist[rand]]:
                print('太棒了')
                break
            else:
                meaning = input(f'再想想，你还有{count}次机会')
                count -= 1
        else:
            print('看来你需要加强记忆哦')
        while True:
            num = input('继续背单词(1:继续 0:退出)?')
            if num == '1':
                wordlist = list(words.keys())
                rand = random.randint(0, len(wordlist) - 1)
                meaning = input(f'请输入单词{wordlist[rand]}的意思：')
                count = 2
                while count > 0:
                    if meaning == words[wordlist[rand]]:
                        print('太棒了')
                        break
                    else:
                        meaning = input(f'再想想，你还有{count}次机会')
                        count -= 1
                else:
                    print('继续背吧')
            else:
                print('退出背单词')
                break
    elif choice == '6':
        print('退出生词本小程序')
        break
    else:
        print('输入信息错误，请重新输入')